<template>
<!--
  <div class="page-header-index-wide">
    <a-row :gutter="24" v-show="false">
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="总销售额" total="￥126,560">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <trend flag="up" style="margin-right: 16px;">
              <span slot="term">周同比</span>
              12%
            </trend>
            <trend flag="down">
              <span slot="term">日同比</span>
              11%
            </trend>
          </div>
          <template slot="footer">日均销售额<span>￥ 234.56</span></template>
        </chart-card>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="访问量" :total="8846 | NumberFormat">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <mini-area />
          </div>
          <template slot="footer">日访问量<span> {{ '1234' | NumberFormat }}</span></template>
        </chart-card>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="支付笔数" :total="6560 | NumberFormat">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <mini-bar :height="40" />
          </div>
          <template slot="footer">转化率 <span>60%</span></template>
        </chart-card>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="运营活动效果" total="78%">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" :height="8" />
          </div>
          <template slot="footer">
            <trend flag="down" style="margin-right: 16px;">
              <span slot="term">同周比</span>
              12%
            </trend>
            <trend flag="up">
              <span slot="term">日环比</span>
              80%
            </trend>
          </template>
        </chart-card>
      </a-col>
    </a-row>

    <a-card :loading="loading" :bordered="false" :body-style="{padding: '0'}" v-show="false">
      <div class="salesCard">
        <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
          <div class="extra-wrapper" slot="tabBarExtraContent">
            <div class="extra-item">
              <a>今日</a>
              <a>本周</a>
              <a>本月</a>
              <a>本年</a>
            </div>
            <a-range-picker :style="{width: '256px'}" />
          </div>
          <a-tab-pane loading="true" tab="销售额" key="1">
            <a-row>
              <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
                <bar title="销售额排行" :dataSource="barData"/>
              </a-col>
              <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
                <rank-list title="门店销售排行榜" :list="rankList"/>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane tab="访问量" key="2">
            <a-row>
              <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
                <bar title="销售额趋势" :dataSource="barData"/>
              </a-col>
              <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
                <rank-list title="门店销售排行榜" :list="rankList"/>
              </a-col>
            </a-row>
          </a-tab-pane>
        </a-tabs>
      </div>
    </a-card>

    <a-row hidden="true">
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="最近一周访问次数统计" :style="{ marginTop: '24px' }">
          <a-row>
            <a-col :span="6">
              <head-info title="今日访问IP数" :content="loginfo.todayIp"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="environment" style="font-size: 24px"  />
              </a-spin>
            </a-col>
            <a-col :span="6">
              <head-info title="今日访问次数" :content="loginfo.todayVisitCount"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="team" style="font-size: 24px"  />
              </a-spin>
            </a-col>
            <a-col :span="6">
              <head-info title="访问总次数" :content="loginfo.totalVisitCount"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="rise" style="font-size: 24px"  />
              </a-spin>
            </a-col>
          </a-row>
          <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
        </a-card>
      </a-col>
    </a-row>
  </div>
-->
  <div class="content" :style="{cursor : cursors}">
    <div class="content-left">
      <ul>
        <li @click="onClick()">
            图片
        </li>
      </ul>
    </div>
    <div class="content-center" ref="dome">
      <div class="dome" 
          v-for="(item, index) in list" 
          :key="index"
          @mousedown="onRoll($event)" 
         :style="{ 
            top: top+'px',
            left: left+ 'px',
            width: Wvalue + 'px' , 
            height: Hvalue + 'px' 
          }"
          ref="boxs" 
      >
          <!--  :style="{top: 200+'px', left: 200+ 'px'}" -->
        <span>X</span>
        <div 
          class="stretching"
          @mousedown="stret($event)"
        >
        </div>
      </div>
      
      
    </div>
    <div class="content-right">
      <h3>属性</h3>
      X:<input type="text" :value="left"/>px<br/>
      Y:<input type="text" :value="top"/>px<br/>
      宽:<input type="text" :value="Wvalue"/>px<br/>
      高:<input type="text" :value="Hvalue"/>px<br/>
    </div>
  </div>
</template>

<script>
 /*  import ChartCard from '@/components/ChartCard'
  import ACol from "ant-design-vue/es/grid/Col"
  import ATooltip from "ant-design-vue/es/tooltip/Tooltip"
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'

  import Trend from '@/components/Trend'
  import { getLoginfo,getVisitInfo } from '@/api/api'

  const rankList = []
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i+1) + ' 号店',
      total: 1234.56 - i * 100
    })
  }
  const barData = []
  for (let i = 0; i < 12; i += 1) {
    barData.push({
      x: `${i + 1}月`,
      y: Math.floor(Math.random() * 1000) + 200
    })
  }
  export default {
    name: "Analysis",
    components: {
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      Trend,
      LineChartMultid,
      HeadInfo
    },
    data() {
      return {
        loading: true,
        center: null,
        rankList,
        barData,
        loginfo:{},
        visitFields:['ip','visit'],
        visitInfo:[],
        indicator: <a-icon type="loading" style="font-size: 24px" spin />
      }
    },
    created() {
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
      this.initLogInfo();
    },
    methods: {
      initLogInfo () {
        getLoginfo(null).then((res)=>{
          if(res.success){
            Object.keys(res.result).forEach(key=>{
              res.result[key] =res.result[key]+""
            })
            this.loginfo = res.result;
          }
        })
        getVisitInfo().then(res=>{
          if(res.success){
             console.log("aaaaaa",res.result)
             this.visitInfo = res.result;
           }
         })
      },
    }
  } */

   export default {
     data(){
       return{
        //  html:'',
        list:0,
        left:0,
        top: 0,
        cursors : 'default',
        Wvalue: '',
        Hvalue: ''
       }
     },
     methods:{
       onClick(){
        //  console.log(1)
          // var str=`
          //   <div class="dome" @click="cesi1()">
          //       <span>X</span>
          //   </div>
          // `
          // this.$refs.html.innerHTML += str
          
          // function cesi1(){
          //     console.log('完美解决');
          // }
          // this.cesi1()
          this.list++;
          
          console.log(this.list)
       },
       
        //拖拽
        onRoll(ev){
          let _event = ev || window.event;  //兼容多个浏览器的event参数模式
          let disX = _event.clientX - this.$refs.boxs[0].offsetLeft
          let disY = _event.clientY - this.$refs.boxs[0].offsetTop
          let domeY = this.$refs.dome.offsetLeft
          // let domeT = 

          console.log(domeY)
          document.onmousemove= (ev) => {
            let _event = ev || window.event;  //兼容多个浏览器的event参数模式
            let left = _event.clientX - disX
            let top = _event.clientY - disY

            if(left < 0 ){
              left = 0
            }else if(left > this.$refs.dome.offsetWidth - this.$refs.boxs[0].offsetWidth ){
              left = this.$refs.dome.offsetWidth - this.$refs.boxs[0].offsetWidth
            }

            if(top< 0 ){
              top = 0
            }else if(top > this.$refs.dome.offsetHeight - this.$refs.boxs[0].offsetHeight){
              top = this.$refs.dome.offsetHeight - this.$refs.boxs[0].offsetHeight
            }
            this.left = left
            this.top = top

            document.onmouseup = (ev)=>{
              document.onmousemove = null;
              document.onmouseup = null;
            }
          }
          // console.log(this.left,  this.top)        
        },
        //拉伸
        stret(ev){
          //阻止默认事件
          event.preventDefault()
          ev.cancelBubble=true;
          let _event = ev || window.event;
          let xDown = _event.clientX,
              yDown = _event.clientY,
              boxsW = this.$refs.boxs[0].clientWidth,
              boxsH = this.$refs.boxs[0].clientHeight;
          this.cursors = "se-resize"
          document.onmousemove = (ev) => {
            event.preventDefault()
            let _event = ev || window.event;
            var xMove = ev.clientX,
                yMove = ev.clientY,
                x_ = xMove - xDown, 
                y_ = yMove - yDown, 
                width = Math.max(10,x_+boxsW),
                height = Math.max(10,y_+boxsH);
            this.Wvalue = width
            this.Hvalue = height
          } 
          document.onmouseup=function () {
            this.cursor = "default";
            document.onmousemove = null;
            document.onmouseup = null;
          }
        }


     },
   }
</script>

<style>
  /* .circle-cust{
    position: relative;
    top: 28px;
    left: -100%;
  }
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  } */

  /* 首页访问量统计 */
 /*  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, .45);
      display: inline-block;
      font-size: .95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }
    p {
      line-height: 42px;
      margin: 0;
      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  } */
  body{
    cursor: auto;
  }
  *{
    margin:0;
    padding:0;
  }
  ul,li{
    list-style:none
  }
  .content{
    display:flex;
    width:100%;
    height:auto;
  }
  .content .content-left{
    width:100px;
    height:auto;
    margin-right:20px;
  }
  .content .content-left ul li {
    height:100px;
    width:100px;
    border:1px solid red;
    
  }
  .content .content-center{
    height:400px;
    width:600px;
    border:1px solid black;
    position:relative;
  }
  .content .content-center .dome{
    height:100px;
    width:100px;
    border:1px solid red;
    position:absolute;
    cursor: auto;
  }
  .content .content-center .dome span{
    cursor:pointer;
    font-size:16px;
    position:absolute;
    top:0;
    right:0;
  }
  .content .content-center .dome .stretching{
      position:absolute;
      bottom:0;
      right:0;
      height: 10px;
      width: 10px;
      /* background: red; */
      /* cursor: pointer; */
  }
  .content .content-right{
    padding:10px;
    margin-left:20px;
    height:auto;
    width:300px;
    border:1px solid black;
  }
  .content .content-right input{
    margin: 10px;
  }

</style>